package com.fujica.invoicing.controller;

import com.fujica.invoicing.service.ICookieService;
import com.fujica.invoicing.utils.Result;
import com.fujica.invoicing.utils.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName CookieController
 * @Description TODO cookie验证
 * @Author admin
 * @Date 2020/8/15 11:33
 * @Version 1.0
 **/

@RestController
@RequestMapping("invoicing/cookie")
@Api(tags = "cookie")
public class CookieController {

    @Autowired
    private ICookieService iCookieService;

    // 获取cookie
    @GetMapping("/{eId}")
    @ApiOperation(value = "获取cookie信息")
    public Result getCookie(@Validated @PathVariable(value = "eId") Integer eId, HttpServletResponse response) {
        if (eId != null && eId > 0) {
            return iCookieService.generateCookie(eId, response);
        }
        return ResultBody.badReq("员工id参数错误");
    }

}
